<?php
class Staff_model extends ci_model{



/*function list_staff($limit, $offset, $sort_by, $sort_order)
{

	 $q = $this->db->get('EMPLOYEE');
      
	  		  if ($q->num_rows()>0)
			  {	
			  foreach ($q->result()as $row )
			  {
			  $data[]=$row;
			  }
			  }
			
		return $data;
	

	
	
	
	}
*/	

function list_staff($limit, $offset, $sort_by, $sort_order)
{
	
	
	 
			$sort_order = ($sort_order == 'desc') ? 'desc' : 'asc';
			$sort_columns = array('TITLE', 'FIRSTNAME', 'LASTNAME', 'CITY', 'POSITION');	
			$sort_by = (in_array($sort_by, $sort_columns)) ? $sort_by : 'TITLE';
	
	
	
	
	
	
		// results query
		$q = $this->db->select('TITLE, FIRSTNAME, LASTNAME, CITY, POSITION')
			->from('EMPLOYEE')
			->limit($limit, $offset)
			->order_by($sort_by, $sort_order);
		
		 $ret['rows'] = $q->get()->result();
	
	
	
	// count query
		$q = $this->db->select('COUNT(*) as count', FALSE)
			->from('EMPLOYEE');
		
		$tmp = $q->get()->result();
		
		$ret['num_rows'] = $tmp[0]->count;
		
		return $ret;
	
	
	
	
	
	
	
	
	}


		



















function add_employee(){

							$data=array(
											
											'TITLE'=>$this->input->post('TITLE'),
											'FIRSTNAME'=>$this->input->post('FIRSTNAME'),
											'LASTNAME'=>$this->input->post('LASTNAME'),
											'MIDDLENAME'=>$this->input->post('MIDDLENAME'),
											'WORKN'=>$this->input->post('WORKN'),
											'MOBILEN'=>$this->input->post('MOBILEN'),
											'HOMEN'=>$this->input->post('HOMEN'),
											'EMAIL'=>$this->input->post('EMAIL'),
											'SEX'=>$this->input->post('SEX'),
											'DOB'=>$this->input->post('DOB'),
											'FLADD'=>$this->input->post('FLADD'),
											'SLADD'=>$this->input->post('SLADD'),
											'POSTCODE'=>$this->input->post('POSTCODE'),
											'DOB'=>$this->input->post('DOB'),
											'CITY'=>$this->input->post('CITY'),
											'COUNTRY'=>$this->input->post('DOB'),
											'POSITION'=>$this->input->post('POSITION'),
											'IMAGEURL'=>$this->input->post('IMAGEURL'),
											'NIN'=>$this->input->post('NIN'),
											'MaritalStatus'=>$this->input->post('MaritalStatus')
											
											);
							
							$insert =$this->db->insert('EMPLOYEE',$data);
							return $insert;
}







}
	
?>